<?php
class IndexNews extends CWidget
{
	public $kind=1;
	public $sum=12;
	public $style='';
	private $images=array(
	1=>'style=" background-image: url(images/bar1.gif);background-position: left -135px;"',
	2=>'style=" background-image: url(images/bar1.gif);background-position: left -162px;"',
	3=>'style=" background-image: url(images/bar1.gif);background-position: left -189px;"'
	);

	public function run()
	{
		$criteria=new CDbCriteria;
		$img='';
		if($this->kind<4){
			$img=$this->images[$this->kind];
			$page='news1';
		}
		elseif($this->kind==4){
			$page='news2';
		}
		elseif($this->kind==5){
			$page='news3';
		}
		elseif($this->kind==6){
			$page='news4';
		}
		$criteria->addCondition('kind='.$this->kind);
		$criteria->addCondition('state=0');
		$criteria->order='create_time desc';
		$criteria->limit=$this->sum;
		$models=News::model()->findAll($criteria);
		$this->render($page,array('models'=>$models,'img'=>$img,'style'=>$this->style,'kind'=>$this->kind));
	}

	
}